﻿using System;
using System.Text;

namespace Furesoft.Database.Client
{
    public class DatabaseConnector
    {
        SimpleClient sc;

        string result;

        public DatabaseConnector(string address, int port)
        {
            sc = new SimpleClient();

            sc.OnReadMessage += sc_OnReadMessage;

            sc.Start(address, port);
        }

        void sc_OnReadMessage(ClientInfo ci, byte[] bytes, int len)
        {
            result = Encoding.UTF8.GetString(bytes);
        }

        public void ExecuteNonQuery(string sql)
        {
            sc.Send(sql);
        }

        public SqlRessource ExecuteQuery(string sql)
        {
            sc.Send(sql);

            return new SqlRessource();
        }
    }
}